/*
 * @Author: tcosfish
 * @Date: 2022-08-03 09:45:42
 * @LastEditors: tcosfish
 * @LastEditTime: 2022-08-03 10:38:14
 * @FilePath: \loadFile\src\database\views\SubjectBalance.view.ts
 */

import { ViewColumn, ViewEntity } from "typeorm"

@ViewEntity({
  expression: `
    SELECT
    \`subject_balance\`.\`code\` AS \`code\`,
    \`subject_balance\`.\`name\` AS \`name\`,
    \`subject_balance\`.\`debit_closing_balance\` AS \`debit\`,
    \`subject_balance\`.\`credit_closing_balance\` AS \`credit\`
    FROM
    \`subject_balance\`
    WHERE
    \`subject_balance\`.\`debit_closing_balance\` IS NOT NULL
    OR \`subject_balance\`.\`credit_closing_balance\` IS NOT NULL
  `,
})
export class SubjectBalanceView {
  @ViewColumn()
  code: string = ""

  @ViewColumn()
  name: string = ""

  @ViewColumn()
  debit: number = -1.0

  @ViewColumn()
  credit: number = -1.0
}
